package com.gonetbar.base.vo;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.apache.log4j.Logger;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.mail.MailParseException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMailMessage;
import org.springframework.mail.javamail.MimeMessageHelper;


public class SpeedAdminEmailMessage{

	
	public SpeedAdminEmailMessage() {
		
		// TODO Auto-generated constructor stub
	}
	private String text;
	private String to;
	private String cc;
	private String bcc;
	private String subject;
	private String  from;
	private ByteArrayOutputStream os;
	private ByteArrayInputStream is;
	private String fileName;

	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public ByteArrayOutputStream getOs() {
		return os;
	}
	public void setOs(ByteArrayOutputStream os) {
		this.os = os;
	}
	public ByteArrayInputStream getIs() {
		return is;
	}
	public void setIs(ByteArrayInputStream is) {
		this.is = is;
	}
	/*public void initializeEmailMessage(JavaMailSender mailSender) {
		// TODO Auto-generated method stub
		mimeMessage = mailSender.createMimeMessage();
		try {
			messageHelper =  new MimeMessageHelper(mimeMessage, true);
			log.info(" initializeEmailMessage(JavaMailSender mailSender)�ɹ� ����");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("SpeedAdminEmailMessageImpl initializeEmailMessage(JavaMailSender mailSender)", e);
			e.printStackTrace();
		}
		
	}
	public void initializeEmailMessage() {
		// TODO Auto-generated method stub
		mimeMessage = this.mailSender.createMimeMessage();
		try {
			messageHelper =  new MimeMessageHelper(mimeMessage, true);
			log.info(" initializeEmailMessage()�ɹ� ����");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error(" SpeedAdminEmailMessageImpl initializeEmailMessage()", e);
			e.printStackTrace();
		}
		
	}

	public void send() {
		// TODO Auto-generated method stub
		try {
			this.messageHelper.setText(this.text, true);
			messageHelper.setTo(this.to.split(";"));
			messageHelper.setCc(this.cc.split(";"));
			messageHelper.setBcc(this.bcc.split(";"));
			messageHelper.setSubject(this.subject);
			messageHelper.setFrom(this.from);
			log.info(" �����ʼ��ɹ� ����"+this.subject);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("SpeedAdminEmailMessageImpl setText()", e);
			e.printStackTrace();
		}
		 mailSender.send(mimeMessage);
	}
*/
	public String getBcc() {
		return bcc;
	}
	public void setBcc(String bcc) {
		this.bcc = bcc;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public String getCc() {
		return cc;
	}
	public void setCc(String cc) {
		this.cc = cc;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	/*public void setFile(ByteArrayOutputStream os){
		 ByteArrayResource file =
             new  ByteArrayResource(os.toByteArray());
		 try {
			 if(this.fileName==null||"".equals(this.fileName.trim())){
				 this.fileName = "unknow_name_file";
			 }
			messageHelper.addAttachment(this.fileName, file);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("SpeedAdminEmailMessageImpl setFile(ByteArrayOutputStream os)", e);
			e.printStackTrace();
		}
	}
	public void setFile(ByteArrayInputStream is){
		InputStreamResource file =  new  InputStreamResource(is);
		 try {
			 if(this.fileName==null||"".equals(this.fileName.trim())){
				 this.fileName = "unknow_name_file";
			 }
			messageHelper.addAttachment(this.fileName, file);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("SpeedAdminEmailMessageImpl setFile(ByteArrayInputStream is)", e);
			e.printStackTrace();
		}
	}*/





	

}
